<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <title>首页</title>
        <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0,user-scalable=no" name="viewport">
        <link rel="stylesheet" href="/css/style.css" type="text/css">
        <link rel="stylesheet" href="/css/font-awesome.css" type="text/css">
    </head>
    <body>
        <div id="index">
            <div class="main_content">
                <div class="mobile">
                    <input type="text" id="mobile" placeholder="充值手机号" />
                </div>
                <div class="goods">
                    <?php foreach($goods as $key=>$good):?>
                    <div>
                        <input type="radio" id="radio<?= $key ?>" name="goods" value="<?= $good ?>" hidden <?php if($good == 50):?>checked<?php endif;?> />
                        <label for="radio<?= $key ?>">
                            <h1><?= number_format($good,2) ?>元</h1>
                            <p>特惠价：<?= number_format($good * ($good == 50 ? '0.95' : '0.93'),2) ?>元</p>
                        </label>
                    </div>
                    <?php endforeach;?>
                </div>
                <div class="submit">
                    <input type="submit" value="立即充值" onclick="app.createOrder()" />
                </div>
            </div>
            <div class="main_footer">
                <a href="/recharge/index/index" class="active">
                    <i class="icon-home"></i>
                    <p>首页</p>
                </a>
                <a href="/recharge/index/user">
                    <i class="icon-user"></i>
                    <p>我的</p>
                </a>
            </div>
        </div>
    </body>
</html>
<script src="http://ss.bdimg.com/static/superman/js/lib/jquery-1.10.2_1c4228b8.js"></script>
<script>
    var app = new (function(){
        
        /** 
         * 创建订单
         * @synopsis function 
         * @return 
         */
        this.createOrder = function(){
            var mobile = $('#mobile').val();
            var goods = $('input[name="goods"]:checked').val();

            if(!mobile){
                alert('请输入手机号！');
                return;
            }
            
            var reg = /^1(3|4|5|7|8)\d{9}$/
            if(!reg.test(mobile)){
                alert('请输入正确手机号！');
                return;
            }

            if(!goods){
                alert('请选择充值手机号！');
                return;
            }

        }
    });
</script>
